/**
 * Created by Jimmy on 15/11/4.
 */
define([
        'app',
        './API'
    ],
    function (app) {
        'use strict';
        app.factory('OrderAPI', ['API', '$resource',
            function (API, $resource) {
                var _API = new API('order');
                var server = _API.server;
                _API.item = angular.extend(new API('order/item'), {});
                return angular.extend(_API, {
                    getOrderItem: function (obj) {//用户id,要取的属性名
                        return $resource(server + '/relations').get(obj).$promise;
                    },
                    dataList: function (index,total) {
                        return $resource(server + '/data/list').get({index:index,total:total}).$promise
                    },
                    dataItem:function(objectId){
                        return $resource(server + '/data/:id').get({id:objectId}).$promise
                    },
                    verifyCoupon:function(objectId){
                        return $resource(server + '/coupon/:code').get({code:objectId}).$promise
                    },
                    anonymousOrder:function(order){
                        return $resource(server + '/anonymous_order').save(order).$promise
                    }
                });
            }
        ]);
    });
